﻿@model Model.CodeManage.GenCodeModel
@{
    Layout = "~/Views/Shared/MyLayOutNew.cshtml";
}
<link rel="stylesheet" type="text/css" href="~/css/style.css" />
<script src="~/javascript/public.js"></script>
<script src="~/javascript/jquery.js"></script>
<main class="main-cont content mCustomScrollbar">
    @using (Html.BeginForm("SaveData", "GenCode", FormMethod.Post))
    {
        @Html.HiddenFor(m=>m.CodeType)
        <div class="page-wrap">
            <!--开始::内容-->
            <section class="page-hd">
                <header>
                    <h2 class="title">生码管理</h2>

                </header>
                <hr>
            </section>
            <div class="form-group-col-2">
                @Html.TextBoxFor(m => m.ID, new { @style = "display:none" })
                <div class="form-label">公司名称：</div>
                <div class="form-cont">
                    @*@Html.TextBoxFor(m => m.EnterpriseId, new { @class = "form-control form-boxed" })*@
                    @Html.DropDownListFor(m => m.EnterpriseId, ViewData["selectList"] as IEnumerable<SelectListItem>, new { @id = "dropdownlist",style="width:30%;" })
                </div>

            </div>
            <div class="form-group-col-2">
                <div class="form-label">生码批次：</div>
                <div class="form-cont">
                    @Html.TextBoxFor(m => m.Batch, new { @class = "form-control form-boxed", @id = "batch", style = "width:30%;", @readonly = "true" })

                </div>

            </div>

            <div class="form-group-col-2">
                <div class="form-label">生码类型：</div>
                <div class="form-cont">
                    <label class="check-box">
                        <input type="checkbox" name="codeTypeTemp" checked="checked" value="1"/>
                        <span>防伪码</span>
                    </label>
                    <label class="check-box">
                        <input type="checkbox" name="codeTypeTemp" checked="checked" value="2" />
                        <span>物流码</span>
                    </label>

                </div>
            </div>


            <div class="form-group-col-2">
                <div class="form-label">横排排版：</div>
                <div class="form-cont">
                    @Html.TextBoxFor(m => m.RankNum, new { @class = "form-control form-boxed", @id = "RankNum", style = "width:30%;" })

                </div>

            </div>
            <div class="form-group-col-2">
                <div class="form-label">竖排排版：</div>
                <div class="form-cont">
                    @Html.TextBoxFor(m => m.VertialNum, new { @class = "form-control form-boxed", @id = "VertialNum", style = "width:30%;" })

                </div>

            </div>


            <div class="form-group-col-2">
                <div class="form-label">生码数量：</div>
                <div class="form-cont">
                    @Html.TextBoxFor(m => m.Gen_Code_Nums, new { @class = "form-control form-boxed", @id = "GenNum", style = "width:30%;" })

                </div>

            </div>

            <div class="form-group-col-2">
                <div class="form-label">防伪码位数：</div>
                <div class="form-cont">
                    <select class="form-control form-boxed" id="Anti_Fake_Num" name="Anti_Fake_Num" style="width:30%;">
                        <option value="18">18</option>
                        <option value="19">19</option>
                        <option value="20">20</option>
                        <option value="21">21</option>
                        <option value="22">22</option>
                        <option value="23">23</option>
                        <option value="24">24</option>

                    </select>

                </div>
            </div>

            <div class="form-group-col-2">
                <div class="form-label">物流码位数：</div>
                <div class="form-cont">
                    <select class="form-control form-boxed" id="Logistics_Num" name="Logistics_Num" style="width:30%;">
                        <option value="16">16</option>
                        <option value="17">17</option>
                        <option value="18">18</option>

                    </select>

                </div>
            </div>
            <div class="form-group-col-2">
                <div class="form-label">数据期限：</div>
                <div class="form-cont">
                    <label class="radio">
                        <input type="radio" name="ExpiryDate" value="0" />
                        <span>无限期</span>
                    </label>
                    <label class="radio">
                        <input type="radio" name="ExpiryDate" checked="checked" value="3" />
                        <span>3年</span>
                    </label>
                    <label class="radio">
                        <input type="radio" name="ExpiryDate" value="2" />
                        <span>2年</span>
                    </label>
                    <label class="radio">
                        <input type="radio" name="ExpiryDate" value="1" />
                        <span>1年</span>
                    </label>
                </div>
            </div>





            <div class="form-group-col-2">
                <div class="form-label"></div>
                <div class="form-cont">
                    <input type="submit" class="btn btn-primary" value="确定"  />
                    <input type="reset" class="btn btn-disabled" value="禁止" />
                </div>
            </div>
            <!--开始::结束-->
        </div>


    }


</main>

<script type="text/javascript">


    $("#dropdownlist").change(function () {
        var eId = $("#dropdownlist").val();
        $.ajax({
            url: '/GenCode/BindBacth',
            type: 'post',
            data: { enterId: eId },
            success: function (batch) {
                $("#batch").val(batch);
            }
        });
    });


    //提交前验证
    $(document).ready(function () {
        $('form').bind('submit', checkform);
    });

    function checkform() {
           var rannum= $("#RankNum").val();
           var vertialNum= $("#VertialNum").val();
           var gennum = $("#GenNum").val();
           var nnn = gennum % (rannum * vertialNum);
           if (gennum % (rannum * vertialNum) != 0) {
               alert("生码数量必须是横排和竖排乘积的倍数！");
               return false;
           }
           else {
               var codeTypeTemp = '';
               $('#CodeType').val('');
               $("input[name='codeTypeTemp']:checkbox:checked").each(function () {
                   codeTypeTemp += $(this).val() + ',';
               })
               $('#CodeType').val(codeTypeTemp);
               return true;
           }
    }

    function Change() {
        var codeTypeTemp = '';
        $('#CodeType').val('');
        $("input[name='codeTypeTemp']:checkbox:checked").each(function () {
            codeTypeTemp += $(this).val() + ',';
        })
        $('#CodeType').val(codeTypeTemp);
    }
</script>